//
//  OrderMessagesignle.m
//  ZLShang
//
//  Created by wangguangming on 15/7/27.
//  Copyright © 2015年 Amber. All rights reserved.
//

#import "OrderMessagesignle.h"
#import "Base.h"
#import "ZLShang.h"
static OrderMessagesignle *signle=nil;
@implementation OrderMessagesignle
+(OrderMessagesignle *)single
{
    if (signle ==nil)
        {
        signle=[[OrderMessagesignle alloc] init];
    } 
    return signle;
}
-(void)orderMessagworking
{
    NSString *urlString=[NSString stringWithFormat:@"%@/api/zls/orders/info/%@",URL,self.oidString];
    NSURL *url=[NSURL URLWithString:urlString];
    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
    [request setHTTPShouldHandleCookies:YES];
    
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *respose,NSData *data,NSError *error){
            // NSLog(@"%@",respose);
        if (error!=nil)
            {
            return ;
            
            }
        NSDictionary *dict= [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; 
        Order *order=[[Order alloc] init];
        [order setValuesForKeysWithDictionary:dict];
        
        self.orderArray=[NSMutableArray arrayWithObject:order];
        NSMutableArray *array=[NSMutableArray arrayWithArray:order.items];
        NSMutableArray *array2=[NSMutableArray array];
            for (NSDictionary *d in array)
                {
                Items *items=[[Items alloc] init];

                [items setValuesForKeysWithDictionary:d];
                [array2 addObject:items];
                 
                }
            self.itemsArray=[NSMutableArray arrayWithArray:array2];
        Consignee *consignee=[[Consignee alloc] init];
        [consignee setValuesForKeysWithDictionary:order.consignee];
        self.consigneeArray=[NSMutableArray arrayWithObject:consignee];
        
        
        NSMutableArray *array3=[NSMutableArray arrayWithArray:order.sendTraces];
        NSMutableArray *array4=[NSMutableArray array];
        for (NSDictionary *d in array3)
            {
            SendTrances * sendTrances=[[SendTrances alloc] init];
            [sendTrances setValuesForKeysWithDictionary:d];
            [array4 addObject:sendTrances];
            }
           self.sendTracesArray=[NSMutableArray arrayWithArray:array4];    
    }];

}
@end
